//
//  EmoticonPackages.swift
//  KeyBoard
//
//  Created by mac on 15/12/26.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class EmoticonPackages: NSObject {
    var id: String?
    var group_name_cn : String?
    
    //创建图片模型数组
    lazy var emoticones = [Emoticons]()
    //kvc构造函数
    init(id:String, group_name_cn:String, emoticons:[[String:String]]){
        super.init()
        self.id = id
        self.group_name_cn = group_name_cn
        var index = 0
        for item in emoticons {
            let e = Emoticons(dict: item)
            //把路径传递过去
            e.id = id
            emoticones.append(e)
            //每20个添加删除按钮
            index++
            if index == 20 {
                let deleteEmoticon = Emoticons(isDelete: true)
                emoticones.append(deleteEmoticon)
                //回复标记
                index = 0
            }
        }
        insetEmptyEmoticons()
    }
    
    private func insetEmptyEmoticons() {
        let detale = emoticones.count % 21
        if detale == 0 {
            return
        }
        for _ in detale..<20{
            emoticones.append(Emoticons(isEmpty: true))
        }
        emoticones.append(Emoticons(isDelete: true))
    }
    
}
